Ext.define('Semoviente', {
    extend: 'Ext.data.Model',
    fields: [
        {name: 'IdSemoviente',type: 'int'},
        {name: 'IdProyecto',type: 'int'},
        {name: 'Proyecto',   type: 'string'},
        {name: 'IdProyectoCPD',type: 'int'},
        {name: 'ProyectoCPD',   type: 'string'},
        {name: 'IdPlanContable',type: 'int'},
        {name: 'NomPlanContable',   type: 'string'},
        {name: 'IdOrigenSemoviente',type: 'int'},
        {name: 'NomOrigenSemoviente',   type: 'string'},
        {name: 'idespecieanimal',type: 'int'},
        {name: 'especie',   type: 'string'},
        {name: 'idcategoriaanimal',type: 'int'},
        {name: 'categoria',   type: 'string'},
        {name: 'IdProyectoCPDU',type: 'int'},
        {name: 'ProyectoCPDU',   type: 'string'},
        {name: 'GProy',   type: 'string'},
        {name: 'Proyecto',   type: 'string'},
        {name: 'AreteMicrochip',   type: 'string'},
        {name: 'FechaNacimiento',   type: 'string'},
        {name: 'EdadMeses',   type: 'string'},
        {name: 'AreteEstablo',   type: 'string'},
        {name: 'Nombre',   type: 'string'},
        {name: 'idrazaanimal',   type: 'int'},
        {name: 'raza',   type: 'string'},
        {name: 'DescSemoviente',   type: 'string'},
        {name: 'IdSemovientePadre',   type: 'string'},
        {name: 'AretePadre',   type: 'string'},
        {name: 'NombrePadre',   type: 'string'},
        {name: 'IdSemovienteMadre',   type: 'string'},
        {name: 'NombreMadre',   type: 'string'},
        {name: 'AreteMadre',   type: 'string'},
        {name: 'TipoIngreso',   type: 'string'},
        {name: 'IdOrigenSemoviente',   type: 'string'},
        {name: 'NomOrigenSemoviente',   type: 'string'},
        {name: 'IdEstadoSemoviente',   type: 'int'},
        {name: 'NomEstadoSemoviente',   type: 'string'},
        {name: 'Peso',   type: 'string'},
        {name: 'Valor',   type: 'string'},
        {name: 'PYUbicacion',   type: 'string'}
    ]
});

Ext.define('EspecieAnimal', {
    extend: 'Ext.data.Model',
    fields: [
        {name: 'idespecieanimal',type: 'int'},
        {name: 'especie',   type: 'string'},
        {name: 'descripcion',   type: 'string'}
    ]
});

Ext.define('MotivoVenta', {
    extend: 'Ext.data.Model',
    fields: [
        {name: 'IdMotivoVenta',type: 'int'},
        {name: 'NomMotivoVenta',   type: 'string'}
    ]
});

Ext.define('CategoriaAnimal', {
    extend: 'Ext.data.Model',
    fields: [
        {name: 'idcategoriaanimal',type: 'int'},
        {name: 'categoria',   type: 'string'},
        {name: 'descripcion',   type: 'string'}
    ]
});

Ext.define('RazaAnimal', {
    extend: 'Ext.data.Model',
    fields: [
        {name: 'idrazaanimal',type: 'int'},
        {name: 'raza',   type: 'string'},
        {name: 'descripcion',   type: 'string'}
    ]
});

Ext.define('OrigenSemoviente', {
    extend: 'Ext.data.Model',
    fields: [
        {name: 'IdOrigenSemoviente',type: 'int'},
        {name: 'NomOrigenSemoviente',   type: 'string'},
        {name: 'DescOrigenSemoviente',   type: 'string'}
    ]
});

Ext.define('EstadoInventario', {
    extend: 'Ext.data.Model',
    fields: [
        {name: 'IdEstadoInventario',type: 'int'},
        {name: 'NomEstado',   type: 'string'},
        {name: 'DescEstado',   type: 'string'}
    ]
});

Ext.define('EstadoSemoviente', {
    extend: 'Ext.data.Model',
    fields: [
        {name: 'IdEstadoSemoviente',type: 'int'},
        {name: 'NomEstadoSemoviente',   type: 'string'},
        {name: 'DescEstadoSemoviente',   type: 'string'}
    ]
});

Ext.define('UbicacionInventario', {
    extend: 'Ext.data.Model',
    fields: [
        {name: 'IdUbicacion',type: 'int'},
        {name: 'NomUbicacion',   type: 'string'},
        {name: 'DescUbicacion',   type: 'string'}
    ]
});

Ext.define('Inventario', {
    extend: 'Ext.data.Model',
    fields: [
        {name: 'IdInventario',type: 'int'},
        {name: 'IdProyecto',   type: 'string'},
        {name: 'CodigoProyecto',   type: 'string'},
        {name: 'CCosto',   type: 'string'},
        {name: 'IdCCosto',   type: 'string'},
        {name: 'IdUbicacion',   type: 'string'},
        {name: 'NomUbicacion',   type: 'string'},
        {name: 'IdCatalogo',   type: 'string'},
        {name: 'Catalogo',   type: 'string'},
        {name: 'Cuenta',   type: 'string'},
        {name: 'CtaDep',   type: 'string'},
        {name: 'IdCtaDep',   type: 'string'},
        {name: 'IdProveedorCliente',   type: 'string'},
        {name: 'RazonSocial',   type: 'string'},
        {name: 'Ruc',   type: 'string'},
        {name: 'Ejercicio',   type: 'string'},
        {name: 'IdEjercicio',   type: 'int'},
        {name: 'IdMes',   type: 'int'},
        {name: 'Mes',   type: 'string'},
        {name: 'FechaIngreso',   type: 'string'},
        {name: 'DescripcionProducto',   type: 'string'},
        {name: 'IdTipoDocumento',   type: 'string'},
        {name: 'NomTipoDocumento',   type: 'string'},
        {name: 'Nrodocumento',   type: 'string'},
        {name: 'IdMarca',   type: 'int'},
        {name: 'NomMarca',   type: 'string'},
        {name: 'Serie',   type: 'string'},
        {name: 'Motor',   type: 'string'},
        {name: 'Placa',   type: 'string'},
        {name: 'IdEstadoInventario',   type: 'int'},
        {name: 'NomEstado',   type: 'string'},
        {name: 'Validado',   type: 'string'},
        {name: 'Codigo',   type: 'string'},
        {name: 'Costo',   type: 'string'},
        {name: 'Depreciacion',   type: 'string'},
        {name: 'Cantidad',   type: 'string'},
        {name: 'Observacion',   type: 'string'},
        {name: 'Donacion',   type: 'string'},
        {name: 'ApeNombre',   type: 'string'},
        {name: 'IdPersonal',   type: 'int'},
        {name: 'IdResponsableInventario',   type: 'string'},
        {name: 'IdDepreciacion',   type: 'string'},
        {name: 'IdEstadoDelInventario',   type: 'string'},
        {name: 'IdInventarioPadre',   type: 'int'}
    ]
});

Ext.define('Anio', {
    extend: 'Ext.data.Model',
    fields: [
        {name: 'IdEjercicio',type: 'int'},
        {name: 'Ejercicio',   type: 'string'}
    ]
});

Ext.define('Mes', {
    extend: 'Ext.data.Model',
    fields: [
        {name: 'IdMes',type: 'int'},
        {name: 'Mes',   type: 'string'}
    ]
});

Ext.define('ResponsableInventario', {
    extend: 'Ext.data.Model',
    fields: [
        {name: 'IdResponsableInventario',type: 'int'},
        {name: 'IdPersonal',   type: 'int'},
        {name: 'Responsable',   type: 'string'},
        {name: 'ApeNombre',   type: 'string'},
        {name: 'FechaIni',   type: 'string'},
        {name: 'FechaFin',   type: 'string'},
        {name: 'Activo',   type: 'string'}
    ]
});

Ext.define('EstadoDelInventario', {
    extend: 'Ext.data.Model',
    fields: [
        {name: 'IdEstadoDelInventario',type: 'int'},
        {name: 'IdInventario',   type: 'int'},
        {name: 'IdEstadoInventario',   type: 'int'},
        {name: 'Fecha',   type: 'string'},
        {name: 'Vigente',   type: 'string'},
        {name: 'NomEstado',   type: 'string'}
    ]
});

Ext.define('UbicacionSemoviente', {
    extend: 'Ext.data.Model',
    fields: [
        {name: 'IdUbicacionSemoviente',type: 'int'},
        {name: 'FechaInicio',   type: 'string'},
        {name: 'FechaFin',   type: 'string'},
        {name: 'Proyecto',   type: 'string'},
        {name: 'Estado',   type: 'bool'}
    ]
});

Ext.define('PropiedadSemoviente', {
    extend: 'Ext.data.Model',
    fields: [
        {name: 'IdPropiedadSemoviente',type: 'int'},
        {name: 'FechaInicio',   type: 'string'},
        {name: 'FechaFin',   type: 'string'},
        {name: 'Valor',   type: 'float'},
        {name: 'Peso',   type: 'float'}
    ]
});

Ext.define('EstadoActualSemoviente', {
    extend: 'Ext.data.Model',
    fields: [
        {name: 'IdEstadoActualSemoviente',type: 'int'},
        {name: 'FechaInicio',   type: 'string'},
        {name: 'FechaFin',   type: 'string'},
        {name: 'NomEstadoSemoviente',   type: 'string'},
    ]
});

Ext.define('CategoriaSemoviente', {
    extend: 'Ext.data.Model',
    fields: [
        {name: 'IdCategoriaSemoviente',type: 'int'},
        {name: 'FechaInicio',   type: 'string'},
        {name: 'FechaFin',   type: 'string'},
        {name: 'categoria',   type: 'string'},
        {name: 'Estado',   type: 'bool'}
    ]
});

Ext.define('VentaSemoviente', {
    extend: 'Ext.data.Model',
    fields: [
        {name: 'IdVenta',type: 'int'},
        {name: 'IdTipoDocumento',   type: 'int'},
        {name: 'NomTipoDocumento',   type: 'string'},
        {name: 'FechaDocumento',   type: 'string'},
        {name: 'NroSerie',   type: 'string'},
        {name: 'NroDocumento',   type: 'string'},
        {name: 'Proyecto',   type: 'string'},
        {name: 'IdProyecto',   type: 'int'},
        {name: 'RazonSocial',   type: 'string'},
        {name: 'IdProveedorCliente',   type: 'int'},
        {name: 'NroVoucher',   type: 'string'},
        {name: 'TipoPago',   type: 'string'},
        {name: 'Estado',   type: 'string'},
        {name: 'NroNotaInterna',   type: 'string'},
        {name: 'Modalidad',   type: 'string'},
        {name: 'NomBanco',   type: 'string'},
        {name: 'FlagVentaAnimales',   type: 'string'},
        {name: 'Transferencia',   type: 'string'},
        {name: 'IdBanco',type: 'int'}
    ]
});

Ext.define('DetalleVenta', {
    extend: 'Ext.data.Model',
    fields: [
        {name: 'IdDetalleVenta',type: 'int'},
        {name: 'IdVenta',   type: 'int'},
        {name: 'Cantidad',   type: 'float'},
        {name: 'PrecioUnitario',   type: 'float'},
        {name: 'IdCatVenta',   type: 'int'},
        {name: 'NomCatVenta',   type: 'string'},
        {name: 'Glosa',   type: 'string'},
        {name: 'IdSemoviente',   type: 'int'},
        {name: 'NomSemoviente',   type: 'string'},
        {name: 'AreteEstablo',   type: 'string'},
        {name: 'IdMotivoVenta',   type: 'int'},
        {name: 'NomMotivoVenta',   type: 'string'},
        {name: 'Total',   type: 'float'}
    ]
});
/*************/
//Raphael.fn.connection = function (obj1, obj2, line, bg) {
//if (obj1.line && obj1.from && obj1.to) {
//line = obj1;
//obj1 = line.from;
//obj2 = line.to;
//}
//var bb1 = obj1.getBBox(),
//bb2 = obj2.getBBox(),
//p = [{x: bb1.x + bb1.width / 2, y: bb1.y - 1},
//{x: bb1.x + bb1.width / 2, y: bb1.y + bb1.height + 1},
//{x: bb1.x - 1, y: bb1.y + bb1.height / 2},
//{x: bb1.x + bb1.width + 1, y: bb1.y + bb1.height / 2},
//{x: bb2.x + bb2.width / 2, y: bb2.y - 1},
//{x: bb2.x + bb2.width / 2, y: bb2.y + bb2.height + 1},
//{x: bb2.x - 1, y: bb2.y + bb2.height / 2},
//{x: bb2.x + bb2.width + 1, y: bb2.y + bb2.height / 2}],
//d = {}, dis = [];
//for (var i = 0; i < 4; i++) {
//for (var j = 4; j < 8; j++) {
//var dx = Math.abs(p[i].x - p[j].x),
//dy = Math.abs(p[i].y - p[j].y);
//if ((i == j - 4) || (((i != 3 && j != 6) || p[i].x < p[j].x) && ((i != 2 && j != 7) || p[i].x > p[j].x) && ((i != 0 && j != 5) || p[i].y > p[j].y) && ((i != 1 && j != 4) || p[i].y < p[j].y))) {
//dis.push(dx + dy);
//d[dis[dis.length - 1]] = [i, j];
//}
//}
//}
//if (dis.length == 0) {
//var res = [0, 4];
//} else {
//res = d[Math.min.apply(Math, dis)];
//}
//var x1 = p[res[0]].x,
//y1 = p[res[0]].y,
//x4 = p[res[1]].x,
//y4 = p[res[1]].y;
//dx = Math.max(Math.abs(x1 - x4) / 2, 10);
//dy = Math.max(Math.abs(y1 - y4) / 2, 10);
//var x2 = [x1, x1, x1 - dx, x1 + dx][res[0]].toFixed(3),
//y2 = [y1 - dy, y1 + dy, y1, y1][res[0]].toFixed(3),
//x3 = [0, 0, 0, 0, x4, x4, x4 - dx, x4 + dx][res[1]].toFixed(3),
//y3 = [0, 0, 0, 0, y1 + dy, y1 - dy, y4, y4][res[1]].toFixed(3);
//var path = ["M", x1.toFixed(3), y1.toFixed(3), "C", x2, y2, x3, y3, x4.toFixed(3), y4.toFixed(3)].join(",");
//if (line && line.line) {
//line.bg && line.bg.attr({path: path});
//line.line.attr({path: path});
//} else {
//var color = typeof line == "string" ? line : "#000";
//return {
//bg: bg && bg.split && this.path(path).attr({stroke: bg.split("|")[0], fill: "none", "stroke-width": bg.split("|")[1] || 3}),
//line: this.path(path).attr({stroke: color, fill: "none"}),
//from: obj1,
//to: obj2
//};
//}
//};
//var el;
//window.onload = function () {
//var dragger = function () {
//this.ox = this.type == "rect" ? this.attr("x") : this.attr("cx");
//this.oy = this.type == "rect" ? this.attr("y") : this.attr("cy");
//this.animate({"fill-opacity": .2}, 500);
//},
//move = function (dx, dy) {
//
////alert('mover');
//var att = this.type == "rect" ? {x: this.ox + dx, y: this.oy + dy} : {cx: this.ox + dx, cy: this.oy + dy};
//this.attr(att);
//for (var i = connections.length; i--;) {
//r.connection(connections[i]);
//}
//r.safari();
//},
//up = function () {
//this.animate({"fill-opacity": 0}, 500);
//},
//r = Raphael("div1", 640, 480),
//connections = [],
//shapes = [ r.ellipse(190, 100, 30, 20),
//r.rect(290, 80, 60, 40, 10),
//r.rect(290, 180, 60, 40, 2),
//r.ellipse(450, 100, 20, 20),
//r.rect(500, 100, 40, 20)
//];
//for (var i = 0, ii = shapes.length; i < ii; i++) {
//var color = Raphael.getColor();
//shapes[i].attr({fill: color, stroke: color, "fill-opacity": 0, "stroke-width": 2, cursor: "move"});
//shapes[i].drag(move, dragger, up);
//}
//connections.push(r.connection(shapes[0], shapes[1], "#000"));
//connections.push(r.connection(shapes[1], shapes[2], "#000", "#fff|5"));
//connections.push(r.connection(shapes[1], shapes[3], "#000", "#fff"));
//connections.push(r.connection(shapes[3], shapes[4], "#000", "#fff"));
//};